
import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()
import { EditBook } from "./EditBook";
import { BookList } from './BookList';
import { PageParams } from '@/types';



export default async function Page({searchParams}: { searchParams: PageParams }) {
  console.log('params', searchParams)
  const { offset = 1, limit = 10 } = searchParams;

  const books = await prisma.bookOfAnswers.findMany({
    take: limit - 0,
    skip: (offset - 1) * limit
  })
  // 获取总数
  const total = await prisma.bookOfAnswers.count()

  return (
    <div className="text-[#333] p-4">
      <EditBook type='add' />
      <BookList books={books} total={total} />
    </div>
  )
}